# Maintainer: Tim Meusel <tim@bastelfreak.de>

_gemname='jwt'
pkgname="ruby-${_gemname}"
pkgver=2.5.0
pkgrel=1
pkgdesc='A pure ruby implementation of the RFC 7519 OAuth JSON Web Token (JWT) standard'
arch=('any')
url="https://github.com/jwt/${pkgname}"
license=('MIT')
depends=('ruby')
makedepends=('ruby-rdoc' 'ruby-rake' 'ruby-rspec' 'ruby-bundler')
options=('!emptydirs')
source=("${url}/archive/v${pkgver}/${_gemname}-v${pkgver}.tar.gz"
        'drop-ci-dependencies.patch')
sha512sums=('fab73ee33769db297b8c8c7381070c8fcd1dd8e43aff2d241ee82f0327867eff3c1067536a90928ad65a2870dc2638515617f5d5cc92023ab1dfe3b6696f10d8'
            'f053410646562d664b4e5401ab86cf8b049393f68c1c232c94482509ed33c5dd796afc1b43ead5078d99dcbeb65ae8011901101e76282fb34ae05f17b3738d14')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  patch -p1 -N -i "${srcdir}/drop-ci-dependencies.patch"
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  gem build "${pkgname}.gemspec"
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  rake test --trace
}

package() {
cd "${srcdir}/${pkgname}-${pkgver}"
  local _gemdir="$(gem env gemdir)"
  gem install --verbose --ignore-dependencies --no-user-install --install-dir "${pkgdir}/${_gemdir}" --bindir "${pkgdir}/usr/bin" "${_gemname}-${pkgver}.gem"

  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"

  install -Dm 644 README.md AUTHORS CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"

  rm -rf "${pkgdir}/${_gemdir}/cache"
}
